#!/bin/bash
# Linux Desktop Beautifier v1.0
# 支持：Ubuntu/Debian/Fedora/CentOS
# 功能：主题/图标/终端美化 + 必备工具集成
# 初始化环境
sudo apt update && sudo apt upgrade -y || sudo dnf update -y
sudo apt install -y git curl wget unzip gnome-tweaks || sudo dnf install -y git curl wget unzip gnome-tweaks
# 安装nerd字体（解决终端图标显示问题）
mkdir -p ~/.fonts && cd ~/.fonts
wget https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/JetBrainsMono.zip
unzip JetBrainsMono.zip && fc-cache -fv
# 安装zsh及oh-my-zsh（终端增强）
sudo apt install -y zsh || sudo dnf install -y zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k
# 安装图形主题（支持GTK3/GTK4）
THEME_DIR="/usr/share/themes"
sudo mkdir -p $THEME_DIR && cd $THEME_DIR
sudo wget https://github.com/jnsh/arc-theme/releases/download/20231030/Arc-20231030.tar.xz
sudo tar -xvf Arc-20231030.tar.xz && sudo rm *.tar.xz
# 安装图标包
ICON_DIR="/usr/share/icons"
sudo mkdir -p $ICON_DIR && cd $ICON_DIR
sudo wget https://github.com/PapirusDevelopmentTeam/papirus-icon-theme/archive/refs/tags/20231001.tar.gz
sudo tar -xvf 20231001.tar.gz && sudo rm *.tar.gz
# 应用主题配置（自动适配桌面环境）
if [ "$XDG_CURRENT_DESKTOP" = "GNOME" ]; then
  gsettings set org.gnome.desktop.interface gtk-theme "Arc-Dark"
  gsettings set org.gnome.desktop.interface icon-theme "Papirus-Dark"
elif [ "$XDG_CURRENT_DESKTOP" = "KDE" ]; then
  lookandfeeltool -a org.kde.breezedark.desktop
  kwriteconfig5 --file kdeglobals --group Icons --key Theme "Papirus-Dark"
elif [ "$XDG_CURRENT_DESKTOP" = "X-Cinnamon" ]; then
  gsettings set org.cinnamon.theme name "Arc-Dark"
  gsettings set org.cinnamon.desktop.interface icon-theme "Papirus-Dark"
fi
# 安装辅助工具
sudo apt install -y neofetch plank || sudo dnf install -y neofetch plank
echo "neofetch" >> ~/.zshrc
# 设置Dock（自动启动）
mkdir -p ~/.config/autostart
cat > ~/.config/autostart/plank.desktop << EOF
[Desktop Entry]
Type=Application
Exec=plank
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=Plank Dock
EOF

# 完成提示
echo "美化已完成！建议："
echo "1. 重启终端应用zsh配置"
echo "2. 运行'p10k configure'配置Powerlevel10k"
echo "3. 在GNOME Tweaks中调整其他外观设置"